<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <meta name="pragma" content="no-cache">
    <meta name="cache-control" content="no-cache">
    <meta name="content-type" content="text/html;charset=UTF-8">
    <meta name="expires" content="0">
    <div th:replace="~{commons/script::script}"></div>
</head>

<body style="width:100%;max-width:600px;padding:30px 60px;">
<section class="info-section">
    <form id="form" method="post">
        <table>
            <tr>
                <td class="text-title">产品名称：</td>
                <td class="text-content">
                    <input type="hidden" name="id" th:value="${product.id}">
                    <input type="text" name="name" th:value="${product.name}"
                           class="easyui-textbox theme-textbox-radius">
                </td>
            </tr>
            <tr>
                <td class="text-title">详情链接：</td>
                <td class="text-content">
                    <input type="text" name="link" th:value="${product.link}"
                           class="easyui-textbox theme-textbox-radius">
                </td>
            </tr>

            <tr>
                <td class="text-title">成本价格：</td>
                <td class="text-content">
                    <input type="text" name="costPrice" th:value="${product.costPrice}"
                           class="easyui-textbox theme-textbox-radius">
                </td>
            </tr>
            <tr>
                <td class="text-title">建议价格：</td>
                <td class="text-content">
                    <input type="text" name="suggestedPrice" th:value="${product.suggestedPrice}"
                           class="easyui-textbox theme-textbox-radius">
                </td>
            </tr>

            <tr>
                <td colspan="2" style="text-align: center;margin-top: 10px;">
                    <a href="javascript:void(0);" id="saveBtn" class="easyui-linkbutton button-primary">修改</a>
                </td>
            </tr>
        </table>
    </form>
</section>
<script type="text/javascript">
    $(function() {


        //为保存按钮添加事件
        $("#saveBtn").on("click",function(event){
            $("#form").form("submit",{
                url:"/product/change",
                onSumbit : function(){
                    //调用easyui中form对象的validate方法对表单中数据进行校验，该方法返回boolean值，如果为false会阻止表单提交
                    return $("#form").form("validate");
                },
                success : function(data){
                    var obj = eval("("+data+")");
                    if(obj.success){
                        $.messager.alert("提示",obj.message);
                        parent.closeTopWindow();
                    }else{
                        $.messager.alert("警告",obj.message);
                    }
                }
            });
        });
    });

</script>
</body>
</html>

